package control;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import event.MotionEvent;
import gui.CameraPanel;
/**
 * ForcedMotion is a control class which functionallity is to
 * put the client in diffrent states: Movie, Idle or Auto.
 *
 */
public class ForcedMotion {
	private ConnectionManager connect;
	private CameraPanel view;

	public ForcedMotion(ConnectionManager connectionManager,
			CameraPanel cameraPanel) {
		this.connect = connectionManager;
		this.view = cameraPanel;
		cameraPanel.addMotionListener(new MovieListener());
		cameraPanel.addNoMotionListener(new IdleListener());
		cameraPanel.addMovieAutoListener(new MovieAutoListener());
		

	}
	/**
	 * Used to register button events (Movie) from the gui
	 *
	 */
	public class MovieListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			connect.getMotionController().setMovieMode();
			connect.getMotionController().putEvent(new MotionEvent(true, "User"));
			

		}
	}
	/**
	 * Used to register button events (Idle) from the gui
	 *
	 */
	public class IdleListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			connect.getMotionController().setIdleMode();
			connect.getMotionController().putEvent(new MotionEvent(false, "User"));
			

		}
	}
	/**
	 * Used to register button events (Auto) from the gui
	 *
	 */
	public class MovieAutoListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			connect.getMotionController().setAutoMode();
			connect.getMotionController().putEvent(new MotionEvent(false, "User"));
			

		}

	}
	
	
}
